Skip to contentSkip to conversation

Change in openvpn[master]: Don't call bytecount client logic in server mode

Openvpn-devel stipa (Code Review) 1 participant 3 messages Aug 27, 2025 – Aug 29, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1756295422000.I7bc7de284fdbfd4be26a907ecd5c21c075bc5ac4@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1157?usp=email

to review the following change.

Change subject: Don't call bytecount client logic in server mode
......................................................................

Don't call bytecount client logic in server mode

Calling this in server mode is wrong because:

- we only output those counters via management interface (>BYTECOUT:) in client mode, so in server mode this is no-op

- the timer callback to fetch DCO stats is triggerer independenty for each peer. It is a waste of resources in server mode where we could fetch stats for all peers with the single ioctl.

Change-Id I7bc7de284fdbfd4be26a907ecd5c21c075bc5ac4

---
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/manage.h

3 files changed, 5 insertions(+), 8 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/57/1157/1

src/openvpn/forward.c +1 -1
index 75ca9d5..e8bdf35 100644
@@ -818,7 +818,7 @@
 #ifdef ENABLE_MANAGEMENT
     if (management)
     {
-        management_check_bytecount(c, management, &c->c2.timeval);
+        management_check_bytecount_client(c, management, &c->c2.timeval);
     }
 #endif /* ENABLE_MANAGEMENT */
 }
src/openvpn/manage.c +3 -6
index aed04f5..f057fb2 100644
@@ -4065,9 +4065,9 @@
 }
 
 void
-management_check_bytecount(struct context *c, struct management *man, struct timeval *timeval)
+management_check_bytecount_client(struct context *c, struct management *man, struct timeval *timeval)
 {
-    if (event_timeout_trigger(&man->connection.bytecount_update_interval, timeval, ETT_DEFAULT))
+    if (!(man->persist.callback.flags & MCF_SERVER) && event_timeout_trigger(&man->connection.bytecount_update_interval, timeval, ETT_DEFAULT))
     {
         counter_type dco_read_bytes = 0;
         counter_type dco_write_bytes = 0;
@@ -4083,10 +4083,7 @@
             dco_write_bytes = c->c2.dco_write_bytes;
         }
 
-        if (!(man->persist.callback.flags & MCF_SERVER))
-        {
-            man_bytecount_output_client(man, dco_read_bytes, dco_write_bytes);
-        }
+        man_bytecount_output_client(man, dco_read_bytes, dco_write_bytes);
     }
 }
 
src/openvpn/manage.h +1 -1
index 083caf5..038691f 100644
@@ -492,7 +492,7 @@
  * These functions drive the bytecount in/out counters.
  */
 
-void management_check_bytecount(struct context *c, struct management *man, struct timeval *timeval);
+void management_check_bytecount_client(struct context *c, struct management *man, struct timeval *timeval);
 
 static inline void
 management_bytes_client(struct management *man, const int size_in, const int size_out)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1157?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7bc7de284fdbfd4be26a907ecd5c21c075bc5ac4
Gerrit-Change-Number: 1157
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1157?usp=email

to look at the new patch set (#2).

Change subject: Don't call bytecount client logic in server mode
......................................................................

Don't call bytecount client logic in server mode

Calling this in server mode is wrong because:

- we only output those counters via management interface (>BYTECOUNT:) in client mode, so in server mode this is no-op

- the timer callback to fetch DCO stats is triggerer independenty for each peer. It is a waste of resources in server mode where we could fetch stats for all peers with the single ioctl.

Change-Id I7bc7de284fdbfd4be26a907ecd5c21c075bc5ac4

---
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/manage.h

3 files changed, 5 insertions(+), 8 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/57/1157/2

src/openvpn/forward.c +1 -1
index 75ca9d5..e8bdf35 100644
@@ -818,7 +818,7 @@
 #ifdef ENABLE_MANAGEMENT
     if (management)
     {
-        management_check_bytecount(c, management, &c->c2.timeval);
+        management_check_bytecount_client(c, management, &c->c2.timeval);
     }
 #endif /* ENABLE_MANAGEMENT */
 }
src/openvpn/manage.c +3 -6
index aed04f5..f057fb2 100644
@@ -4065,9 +4065,9 @@
 }
 
 void
-management_check_bytecount(struct context *c, struct management *man, struct timeval *timeval)
+management_check_bytecount_client(struct context *c, struct management *man, struct timeval *timeval)
 {
-    if (event_timeout_trigger(&man->connection.bytecount_update_interval, timeval, ETT_DEFAULT))
+    if (!(man->persist.callback.flags & MCF_SERVER) && event_timeout_trigger(&man->connection.bytecount_update_interval, timeval, ETT_DEFAULT))
     {
         counter_type dco_read_bytes = 0;
         counter_type dco_write_bytes = 0;
@@ -4083,10 +4083,7 @@
             dco_write_bytes = c->c2.dco_write_bytes;
         }
 
-        if (!(man->persist.callback.flags & MCF_SERVER))
-        {
-            man_bytecount_output_client(man, dco_read_bytes, dco_write_bytes);
-        }
+        man_bytecount_output_client(man, dco_read_bytes, dco_write_bytes);
     }
 }
 
src/openvpn/manage.h +1 -1
index 083caf5..038691f 100644
@@ -492,7 +492,7 @@
  * These functions drive the bytecount in/out counters.
  */
 
-void management_check_bytecount(struct context *c, struct management *man, struct timeval *timeval);
+void management_check_bytecount_client(struct context *c, struct management *man, struct timeval *timeval);
 
 static inline void
 management_bytes_client(struct management *man, const int size_in, const int size_out)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1157?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7bc7de284fdbfd4be26a907ecd5c21c075bc5ac4
Gerrit-Change-Number: 1157
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#3 lore raw
In reply to a message not in the archive

stipa has abandoned this change. ( http://gerrit.openvpn.net/c/openvpn/+/1157?usp=email )

Change subject: Don't call bytecount client logic in server mode
......................................................................

Abandoned

Will be superceded
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1157?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7bc7de284fdbfd4be26a907ecd5c21c075bc5ac4
Gerrit-Change-Number: 1157
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: abandon